<template>
	<view class="list-box">
		<view id="nogonggao" v-if="list.length<1">
		    还没有公告信息
		</view>
		<view class="item" v-for="(item,i) in list" :key="item.id" @click="goDetail(item.id)">
			<view class="title">
				<view class="gtitle">{{item.title}}</view>
				<view class="gtime">{{item.createTime}}</view>
			</view>
			<view class="summary-box">
				<mp-html :content="switchImage(item.message)" />
			</view>
		</view>
	</view>
</template>

<script>
	import mpHtml from '@/components/mp-html/mp-html'
	export default {
		data() {
			return {
				list:[]
			}
		},
		methods: {
			goDetail(n){
				uni.navigateTo({
					url:"gonggaoDetail?id="+n
				})
			},
			// 转换图片地址
			switchImage(url){
				var reg = /\"\/image/g;
				url = url.replace(reg,'"'+this.host+'/image');
				return url.substr(0,120);
			}
		},
		onLoad() {
			this.$http.get('/pp_tongzhi/getTongzhi', {
				gsid:0,
				page:1,
				limit:10
			}).then(res => {
				this.list = res.data.data;
			})
		},
		components:{
			mpHtml
		}
	}
</script>

<style scoped>
	.list-box{
		margin-top: 20rpx;
	}
	.title{
		display: flex;
		justify-content: space-between;
		margin-bottom: 10rpx;
	}
	.item{
		background-color: white;
		padding: 30rpx;
		border-bottom: 1px solid #ccc;
	}
	.item .gtitle{
		font-size: 32rpx;
		color: #2979FF;
	}
	.item .gtime{
		font-size: 24rpx;
		color: #CCCCCC;
	}
	.summary-box{
		display:-webkit-box;
		overflow:hidden;
		text-overflow:ellipsis;
		-webkit-line-clamp:1;
		-webkit-box-orient:vertical;
	}
	.summary-box img{
		max-width: 20rpx !important;
	}
	#nogonggao{
		text-align: center;
		margin-top: 50px;
	}
</style>
